<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta name="format-detection" content="telephone=no">
    <title>新增停车券</title>
    <link rel="stylesheet" href="${ctx}/static/plug/frozenui-1.3.0/css/frozen.css" media="all">
    <link rel="stylesheet"
          href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.4/css/bootstrap-select.min.css">


    <style type="text/css">
        input {
            border: #9a9999 0px solid;
            BORDER-BOTTOM: #9a9999 1px solid;
            width: 100%;
            height: 43px;
            line-height: 30px;
            vertical-align: middle;
            BACKGROUND-COLOR: transparent;
        }

        .ui-div-type {
            height: 43px;
            width: 40%
        }

        .select-type {
            height: 43px;
        }

        .text_alert{
            border-color: #FF4500 !important;
            border-style: solid  !important;
            border-top-width: 0px  !important;
            border-right-width: 0px  !important;
            border-bottom-width: 1px  !important;
            border-left-width: 0px  !important;
        }

    </style>
</head>
<body ontouchstart="">
<section class="ui-container">
    <div style="margin:0 auto;width:90%;padding-top:50px">
        <div class="ui-whitespace">
            <p class="ui-txt-info" style="padding-bottom: 3%">新增停车券</p>
        </div>

        <div class="ui-form ui-border-t">
            <div class="ui-form-item ui-form-item-show ui-border-b">

                <label style="width: 25%">金&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;额:</label>
                <ul class="ui-tiled" style="width: 75%;margin-left: 25px" align="right">
                    <li>
                        <button style="width: 30px" id="btnReduceMoney" class="ui-btn-primary">
                            &nbsp;&nbsp;-&nbsp;&nbsp;</button>
                        <span id="money">20</span>
                        <button style="width: 30px" id="btnPlusMoney" class="ui-btn-primary">
                            &nbsp;&nbsp;+&nbsp;&nbsp;</button>
                    </li>
                </ul>
                <div style="width: 70%">

                    <input type="text" id="name" value=""/>

                </div>

            </div>
            <div class="ui-form-item ui-form-item-show ui-border-b">
                <label style="width: 25%">有效时间:</label>
                <div class="ui-select ui-div-type">
                    <select class="select-type" id="validType">
                    </select>
                </div>
            </div>
        </div>

        <div style="padding-top: 30px;" align="center">
            <button type="button" class="ui-btn ui-btn-primary" style="width: 100%;height: 40px"
                    id="btnConfirm">保存
            </button>
            <button type="button" class="ui-btn" style="margin-top:10px; width: 100%; height: 40px"
                    id="btnCancel">取消
            </button>
        </div>

    </div>
</section>
</body>
<script src="${ctx}/static/plug/frozenui-1.3.0/lib/zepto.min.js"></script>
<script src="${ctx}/static/plug/frozenui-1.3.0/js/frozen.js"></script>
<script>

    var paramObj = {
        "newShopCouponParams": "${newShopCouponParams}",
        "shopCouponListParams": "${shopCouponListParams}"
    };


    $(function () {
        $.queryCode($("#validType"), "couponValidType");

        $("#btnReduceMoney").click(function () {
            var money = parseInt($("#money").html());
            $("#money").html(money - 1);
        });
        $("#btnPlusMoney").click(function () {
            var money = parseInt($("#money").html());
            $("#money").html(money + 1);
        });

        $("#btnCancel").click(function () {
            var hrefUrl = "${action}?params=" + paramObj.shopCouponListParams;
            window.location.href = hrefUrl;
        });

        var canSubmit = true;
        $("#btnConfirm").click(function () {
            if (canSubmit) {
                if (!$("#validType").val()) {
                    showTips("warn", "请选择有效时间类型!");
                    $("#validType").addClass("text_alert");
                    return;
                }
                var paraObj = {
                    "params": paramObj.newShopCouponParams,
                    "money": $("#money").html(),
                    "validType": $("#validType").val()
                };
                canSubmit = false;
                $.post("${action}", paraObj, function (obj) {
                    if (obj.result) {
                        showTips("info", "新增定成功");
                        var hrefUrl = "${action}?params=" + paramObj.shopCouponListParams;
                        window.location.href = hrefUrl;
                    } else {
                        $("#showMsgP").html(obj.msg);
                    }
                    canSubmit = true;
                });
            }
        });
    });


</script>
</html>